import axios from 'axios';
import router from '@/main'
import { Message } from 'element-ui';
import cookieConfig from '@/utils/getCookie';
import store from '@/vuex/store';
import qs from 'qs';
import Vue from 'vue'
var URLS =  window.process.config.API_BASEURL;
console.log(URLS)
var serviceId = window.localStorage.getItem("serviceId");
// 略缩图
var fileUrl = window.process.config.file_BASEURL;
// console.log(fileUrl)
window.localStorage.setItem("editUrl",fileUrl);
let token = localStorage.getItem("token");


/**
 * 基本封装axios
 */
function request (options) {
    return new Promise((resolve, reject) => {
        // 基本设置
        const instance = axios.create({
            baseURL: window.process.config.API_BASEURL, // 从环境进程中根据运行环境获取的api的base_url
            timeout: 50000, // 请求超时时间
            withCredentials:true,//携带cookie
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            responseType : 'json',
            // // maxContentLength: 2000,
            // transformRequest: [function (data) {
            //     data = qs.stringify(data);
            //     return data
            // }],
            // transformResponse: [function (data) {
            //     return data;
            // }]
        });
        // 请求拦截
        instance.interceptors.request.use(
            
            config => {
                if (config.method === 'POST' || config.method === 'put') {
                    // debugger
                    // config.data = qs.stringify(config.data);
                    config.headers['Content-Type'] =  'application/json;charset=UTF-8';
                }
                // 存储token在store
                if(!token){
                    token = localStorage.getItem("token");
                }
                if(token) {
                    config.headers.Authorization = 'Bearer'+' '+token;
                }
                return config;
                // if (store.getters.access_token) {
                //     config.headers.authorization = store.getters.access_token;
                // }
            },
            error => {
                Message.error({
                    message: '加载超时',
                    type: 'error',
                    duration: 10 * 1000
                });
                return Promise.reject(error)
            });
        // 返回拦截
        instance.interceptors.response.use(
            response => {
                // 判断data不是Object时，解析成blob
                // if(!(response.data instanceof Object)){
                //     response.data = new Blob([response.data])
                // }
                console.log(response)
                return response
            },
            error => {
                console.log(error.response,'----------------------')
                if(error.response && error.response.status === 302){
                     　window.location.href= error.response.headers.Location; 

                }else if (error.response === undefined || error.response === null || error.response.status === undefined) {
                    Message({
                        message: '连接服务器失败!',
                        type: 'error',
                        duration: 10 * 1000,
                        showClose: true,
                    });
                    router.replace({
                        path:'/login/login'
                        // query: {redirect: router.currentRoute.fullPath}
                    })
                } else if(error.response.status === 401||error.response.status === 412){
                    Message({
                        message: '加载超时!',
                        type: 'error',
                        duration: 10 * 1000,
                        // showClose: true,
                    });
                    router.replace({
                        path:'/login/login'
                        // query: {redirect: router.currentRoute.fullPath}
                    })
                    // store.dispatch('FedLogOut').then(() => {
                    //     location.reload();// 为了重新实例化vue-router对象 避免bug
                    // });
                } else {
                    Message({
                        message: error.message,
                        type: 'error',
                        duration: 10 * 1000,
                        showClose: true,
                    })
                }
                return Promise.reject(error) // 错误信息
            });
        //请求处理
        instance(options)
            .then((res) => {
                resolve(res.data);
                return false
            })
            .catch((error) => {
                reject(error)
            })
    })
}

function requestFile (options) {
    return new Promise((resolve, reject) => {
        // 基本设置
        const instance = axios.create({
            baseURL: fileUrl, // 从环境进程中根据运行环境获取的api的base_url
            // timeout: 50000, // 请求超时时间
            withCredentials:true,//携带cookie
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
                'X-Requested-With': 'XMLHttpRequest',
            },
            responseType : 'json',
            // // maxContentLength: 2000,
            transformRequest: [function (data) {
                data = qs.stringify(data);
                return data
            }],
            transformResponse: [function (data) {
                return data;
            }]
        });
        // 请求拦截
        instance.interceptors.request.use(
            config => {
                if (config.method === 'post' || config.method === 'put') {
                    config.data = qs.stringify(config.data);
                    config.headers['Content-Type'] =  'application/x-www-form-urlencoded';
                }
                if(token) {
                    config.headers.Authorization = 'Bearer'+' '+token;
                }
                return config;
                // 存储token在store
                // if (store.getters.access_token) {
                //     config.headers.authorization = store.getters.access_token;
                // }
            },
            error => {
                Message.error({
                    message: '加载超时',
                    type: 'error',
                    duration: 10 * 1000,
                    showClose: true,
                });
                return Promise.reject(error)
            });
        // 返回拦截
        instance.interceptors.response.use(
            response => {
                // 判断data不是Object时，解析成blob
                // if(!(response.data instanceof Object)){
                //     response.headers['Content-Type'] =  'blob';
                //     response.data = new Blob([response.data])
                // }
                
                if (response.errorCode == 'SEC-00009' || (response.data && response.data.errorCode == 'SEC-00009') ) {
                    // window.location.href='/#/login/Login';
                    router.push({
                        path:'/login/Login'
                    })
                }
                return response
            },
            error => {
                console.log(error.response.status,'22222222222222')
                if(error.response.status === 302){
                    　window.location.href= error.response.headers.Location; 
        
               }else if (error.response === undefined || error.response.status === undefined) {
                    Message({
                        message: '连接服务器失败!',
                        type: 'error',
                        duration: 2 * 1000,
                        showClose: true,
                    });
                    router.replace({
                        path:'/login/login'
                        // query: {redirect: router.currentRoute.fullPath}
                    })
                } else if(error.response.status === 401||error.response.status === 412){
                    Message({
                        message: '加载超时!',
                        type: 'error',
                        duration: 2 * 1000,
                        // showClose: true,
                    });
                    router.replace({
                        path:'/login/login'
                        // query: {redirect: router.currentRoute.fullPath}
                    })
                   
                    // store.dispatch('FedLogOut').then(() => {
                    //     location.reload();// 为了重新实例化vue-router对象 避免bug
                    // });
                } else {
                    Message({
                        message: error.message,
                        type: 'error',
                        duration: 10 * 1000,
                        showClose: true,
                    })
                }
                return Promise.reject(error) // 错误信息
            });
        //请求处理
        instance(options)
            .then((res) => {
                resolve(res.data);
                return false
            })
            .catch((error) => {
                reject(error)
            })
    })
}

let video = axios.create({
    baseURL:  window.process.config.video_BASEURL, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 60*1000, // 请求超时时间
    withCredentials:true,//携带cookie
    // timeout: 240000, // 请求超时时间
});

video.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    });

function resetToken(_http){
    if(!localStorage.getItem('token')){
        token = null;
    } else if(!token || token !== localStorage.getItem('token')) {
        token = localStorage.getItem('token');
    }
    _http.interceptors.request.use(
        config => {
            if(!token) {
                token = localStorage.getItem('token');
            }
            if(token) {
                config.headers.Authorization = 'Bearer'+' '+token;
            }
            return config;
        },
        error => {
            Message.error({
                message: '加载超时',
                type: 'error',
                duration: 5 * 1000
            });
        });
    return _http;
}
/*----------------------baseUrl http begin------------------------------------*/
let $http = axios.create({
    baseURL: window.process.config.API_BASEURL, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 50000, // 请求超时时间
    withCredentials:true,//携带cookie
});

// 请求拦截
$http.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    }
);

// 返回拦截
$http.interceptors.response.use(
    response => {
        if (response.errorCode == 'SEC-00009' || (response.data && response.data.errorCode == 'SEC-00009') ) {
           // window.location.href='/#/login/Login';
            router.push({
                path:'/login/Login'
            })
        }
        return response
    },
    error => {
        console.log(error.response.status)
        if(error.response.status === 302){
            window.location.href= error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined||error.response.status === 500||error.response.status === 504) {
            Message({
                message: '连接服务器失败!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
                // showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 10 * 1000,
                showClose: true,
            })
        }
    }
);

const $httpBlob = axios.create({
    baseURL:window.process.config.API_BASEURL,
    // baseURL: baseUrl, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 180*1000, // 请求超时时间
    responseType: 'blob',
    withCredentials:true,//携带cookie
});

// 请求拦截
$httpBlob.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    }
);

// 返回拦截
$httpBlob.interceptors.response.use(
    response => {
        return response
    },
    error => {
        if(error.response.status === 302){
            window.location.href = error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined) {
            Message({
                message: '连接服务器失败!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
                // showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 10 * 1000,
                showClose: true,
            })
        }
    }
);

const $httpSearch = axios.create({
    baseURL: window.process.config.API_BASEURL, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 50000, // 请求超时时间
    withCredentials:true,//携带cookie
});

$httpSearch.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    }
);

// 返回拦截
$httpSearch.interceptors.response.use(
    response => {
        return response
    },
    error => {
        console.log(error.response.status)
        if(error.response.status === 302){
            window.location.href= error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined) {
            Message({
                message: '连接服务器失败!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
                // showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 10 * 1000,
                showClose: true,
            })
        }
    }
);
const $httpImport = axios.create({
    baseURL:window.process.config.API_BASEURL,
    // baseURL: baseUrl, // 从环境进程中根据运行环境获取的api的base_url
    headers: {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"},
    withCredentials:true,//携带cookie
});
/*----------------------baseUrl http end------------------------------------*/

/*----------------------fileUrl http begin------------------------------------*/
let fileUp = axios.create({
    baseURL: fileUrl, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 60*1000, // 请求超时时间
    withCredentials:true,//携带cookie
    // timeout: 240000, // 请求超时时间
});

fileUp.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    });

//返回拦截
fileUp.interceptors.response.use(
    response => {
        return response
    },
    error => {
        if(error.response.status === 302){
            window.location.href= error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined) {
            Message({
                message: '服务器繁忙，请稍后重试!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 5 * 1000
            })
        }
    });

let $httpFile = axios.create({
    baseURL: fileUrl, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 30000, // 请求超时时间
    withCredentials:true,//携带cookie
});

$httpFile.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    }
);

// 返回拦截
$httpFile.interceptors.response.use(
    response => {
        return response
    },
    error => {
        if(error.response.status === 302){
            window.location.href= error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined) {
            Message({
                message: '服务器繁忙，请稍后重试!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 5 * 1000
            })
        }
    }
);

let $httpFileBlob = axios.create({
    baseURL: fileUrl, // 从环境进程中根据运行环境获取的api的base_url
    timeout: 180*1000, // 请求超时时间
    responseType: 'blob',
    withCredentials:true,//携带cookie
});

// 请求拦截
$httpFileBlob.interceptors.request.use(
    config => {
        if(token) {
            config.headers.Authorization = 'Bearer'+' '+token;
        }
        return config;
    },
    error => {
        Message.error({
            message: '加载超时',
            type: 'error',
            duration: 5 * 1000
        });
    }
);

// 返回拦截
$httpFileBlob.interceptors.response.use(
    response => {
        return response
    },
    error => {
        if(error.response.status === 302){
            window.location.href = error.response.headers.Location;

        }else if (error.response === undefined || error.response.status === undefined) {
            Message({
                message: '连接服务器失败!',
                type: 'error',
                duration: 2 * 1000,
                showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else if(error.response.status === 401||error.response.status === 412){
            Message({
                message: '加载超时!',
                type: 'error',
                duration: 2 * 1000,
                // showClose: true,
            });
            router.replace({
                path:'/login/login'
                // query: {redirect: router.currentRoute.fullPath}
            })
        } else {
            Message({
                message: error.message,
                type: 'error',
                duration: 10 * 1000,
                showClose: true,
            })
        }
    }
);
/*----------------------fileUrl http end------------------------------------*/
function createFileAxios(){

    let url = fileUrl;

    fileUp = axios.create({
        baseURL: url,
        timeout: 60*1000, // 请求超时时间
        withCredentials:true,//携带cookie
        // timeout: 240000, // 请求超时时间
    });
    fileUp.interceptors.request.use(
        config => {
            if(token) {
                config.headers.Authorization = 'Bearer'+' '+token;
            }
            return config;
        },
        error => {
            Message.error({
                message: '加载超时',
                type: 'error',
                duration: 5 * 1000
            });
        });
    //返回拦截
    fileUp.interceptors.response.use(
        response => {
            return response
        },
        error => {
            if(error.response.status === 302){
                window.location.href= error.response.headers.Location;

            }else if (error.response === undefined || error.response.status === undefined) {
                Message({
                    message: '服务器繁忙，请稍后重试!',
                    type: 'error',
                    duration: 2 * 1000,
                    showClose: true,
                });
            } else if(error.response.status === 401||error.response.status === 412){
                Message({
                    message: '加载超时!',
                    type: 'error',
                    duration: 2 * 1000,
                });
                router.replace({
                    path:'/login/login'
                    // query: {redirect: router.currentRoute.fullPath}
                })
            } else {
                Message({
                    message: error.message,
                    type: 'error',
                    duration: 5 * 1000
                })
            }
        });
}


// baseURL: window.process.config.NODE_ENV==='development'?window.process.config.`:abc,

/*----------------------------------baseUrl begin-----------------------------------*/
/**
 * get请求
 * @param url 接口地址
 * @param params 参数 (query params)
 * @returns {Promise<R>|Promise<U>}
 */
function requestGet(url,params){
    return request({
        method: 'GET',
        url: url,
        params,
    });
}

function requestFormPost(url,data){
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    // return $httpFileBlob.post(url, data, options)
    // return $httpSearch.post(url, data, options)
    console.log(data)
    return request({
        method: 'POST',
        url,
        data,
    });
}

function requestHtmlGet(url,params){
    return request({
        method: 'GET',
        url: url,
        params,
        responseType: 'text/html'
    });
}

function requestBlobGet(url,params){
    return request({
        method: 'GET',
        url: url,
        params,
        responseType: 'blob'
    });
}

function requestBlobPost(url,data){
    return request({
        method: 'Post',
        url: url,
        data,
        responseType: 'blob'
    });
}

function requestPdfGet(url,params){
    return request({
        method: 'GET',
        url: url,
        params,
        responseType: 'application/pdf'
    });
}
// 下载
function fileDownBlobPost(url,data){
    return fileUp({
        method: 'POST',
        url: url,
        data,
        responseType: 'blob'
    });
 }
// 获取视频
 function requestVideoGet(url,data){
    return video({
        method: 'POST',
        url: url,
        data,
        responseType: 'blob'
    });
 }
/**
 * post请求
 * @param url 接口地址
 * @param data 参数（request payLoad）
 * @returns {Promise<R>|Promise<U>}
 */
function requestJsonPost(url,data){     
    if(typeof(data)=== "number" ){
       data = ''+ data;
    }
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    if(!token || token !== localStorage.getItem("token")){
        $http = resetToken($http);
    }
    return $http.post(url, data, options)
}


/**
 * post请求
 * @param url 接口地址
 * @param data 参数（request payLoad）
 * @returns {Promise<R>|Promise<U>}
 */
function requestSearchJsonPost(url,data){
    if(typeof(data)=== "number" ){
        data = ''+ data;
    }
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    return $httpSearch.post(url, data, options)
}
/*----------------------------------baseUrl end-----------------------------------*/

/*----------------------------------fileUrl begin-----------------------------------*/

function requestBlobGetFile(url,params){
    return requestFile({
        method: 'GET',
        url: url,
        params,
        responseType: 'blob'
    });
}

function requestJsonPostFile(url,data){
    if(serviceId !==  window.localStorage.getItem("serviceId")) {
        serviceId =  window.localStorage.getItem("serviceId");
        createFileAxios();

    }
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    return $httpFile.post(url, data, options)
}

function requestBlobPostFile(url,data){
    if(serviceId !==  window.localStorage.getItem("serviceId")) {
        serviceId =  window.localStorage.getItem("serviceId");
        createFileAxios();
    }
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    return $httpFileBlob.post(url, data, options)
}

/**
 * 断点续传
 * @param （form data）
 */
// 开始预备(暂停/继续/查询)
function upLoadPreGet(url,params){
    if(serviceId !==  window.localStorage.getItem("serviceId")) {
        serviceId =  window.localStorage.getItem("serviceId");
        createFileAxios();
    }
    return fileUp({
        method: 'GET',
        url: url,
        params,
        paramsSerializer: data => {
            return qs.stringify(data, { indices: false })
        }
    });
}

// 开始预备(暂停/继续/查询)
function upLoadPrePost(url,data){
    if(serviceId !==  window.localStorage.getItem("serviceId")) {
        serviceId =  window.localStorage.getItem("serviceId");
        createFileAxios();
    }
    const headers = {'Content-Type': 'application/json;charset=UTF-8'};
    const options = {headers : headers};
    return fileUp.post(url, data, options)
}

// 上传
function upLoadFormPost(url,data){
    if(serviceId !==  window.localStorage.getItem("serviceId")) {
        serviceId =  window.localStorage.getItem("serviceId");
        createFileAxios();
    }
    return fileUp({
        method: 'POST',
        url: url,
        data:data,
    });
}

/*----------------------------------fileUrl end-----------------------------------*/

/**
 * post请求
 * @param url 接口地址
 * @param data 参数（form data）
 * @returns {Promise<R>|Promise<U>}
 */
function requestFormPostImport(url,data){
    return $httpImport.post(url,data)
}

Vue.prototype.baseURL = window.process.config.API_BASEURL;

const HttpRequest = {
    requestGet,
    requestJsonPost,
    requestSearchJsonPost,
    // requestJsonPost1,
    requestFormPost,
    requestBlobGet,
    requestPdfGet,
    // requestJsonGet,
    requestHtmlGet,
    // requestJsonFtp,
    upLoadPreGet,
    upLoadPrePost,
    upLoadFormPost,
    requestFormPostImport,
    // requestBlobGet1,
    requestBlobGetFile,
    requestJsonPostFile,
    requestBlobPostFile,
    requestBlobPost,
    // requestBlobPost1,
    // requestBlobPost2,
    fileUrl,
    URLS,
    fileDownBlobPost,
    requestVideoGet,
};

export default HttpRequest;

/*
*
--------基本封装---------------------------
request baseUrl
requestFile fileUrl
createFileAxios 改变9093地址，重建9093的连接

--------9090 baseUrl archive服务请求---------------------------
定义http对象
http 数据请求
httpBlob 文件上传下载导入导出
httpSearch 检索用
定义接口
1.requestGet get请求 responseType : 'json',
2.requestJsonPost post 'Content-Type': 'application/json;charset=UTF-8' json请求
3.requestBlobGet  get responseType: 'blob' 下载
4.requestBlobPost post responseType: 'blob' 下载
5.requestHtmlGet get html responseType: 'text/html'
6.requestPdfGet get pdf responseType: 'application/pdf'
7.requestFormPost post content-type application/x-www-form-urlencoded
8.requestSearchJsonPost 'Content-Type': 'application/json;charset=UTF-8' json请求
9.requestFormPostImport  post content-type application/x-www-form-urlencoded 需测试是否可以用requestFormPost替换

----------9093 fileUrl 文件服务请求------------------------------
定义http对象
httpFile
httpFileBlob
fileUp 大文件上传专用
定义接口
1.requestBlobGetFile get responseType: 'blob' 下载文件
2.requestJsonPostFile 'Content-Type': 'application/json;charset=UTF-8' 删除文件
3.requestBlobPostFile post responseType: 'blob' 下载文件

---------（大文件上传专用）----------
5.upLoadPreGet 开始预备上传（大文件上传专用）
4.upLoadFormPost 上传文件
6.upLoadPrePost 'Content-Type': 'application/json;charset=UTF-8' （大文件上传专用）
*
* */